package com.zbkj.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.common.model.record.UserVisitRecord;
import com.zbkj.service.dao.UserVisitRecordDao;
import com.zbkj.service.service.UserVisitRecordService;
import com.zbkj.service.util.BrandUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * UserVisitRecordServiceImpl 接口实现
 +----------------------------------------------------------------------
 */
@Service
public class UserVisitRecordServiceImpl extends ServiceImpl<UserVisitRecordDao, UserVisitRecord> implements UserVisitRecordService {

    @Resource
    private UserVisitRecordDao dao;

    /**
     * 通过日期获取浏览量
     * @param date 日期
     * @return Integer
     */
    @Override
    public Integer getPageviewsByDate(String date) {
        QueryWrapper<UserVisitRecord> wrapper = new QueryWrapper<>();
        wrapper.eq("date", date);
        return dao.selectCount(wrapper);
    }
    @Override
    public Integer getPageviewsByDateBrand(String date) {
        QueryWrapper<UserVisitRecord> wrapper = new QueryWrapper<>();
        wrapper.eq("date", date);
        wrapper.eq("brand_id", BrandUtil.getBrandIdByUrl());
        return dao.selectCount(wrapper);
    }

}

